package unrn.isiii.bean.rest;

import java.util.List;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import unrn.isiii.dao.ISitioDao;
import unrn.isiii.model.Sitio;

@Component
@Path("/sitio")
public class SitioRestService {

	@Autowired
	ISitioDao iSitioDao;

	@GET
	@Path("/get/{id}")
	@Produces(MediaType.APPLICATION_JSON)
	public Sitio consulta(@PathParam("id") String id) {

		try {
			return getiSitioDao().find(id);
		} catch (Exception e) {
			return new Sitio();
		}

	}
	
	
	@GET
	@Path("/lista")
	@Produces(MediaType.APPLICATION_JSON)
	public List<Sitio> lista() {

		try {
			return getiSitioDao().findAll();
		} catch (Exception e) {
			return null;
		}

	}

	public ISitioDao getiSitioDao() {
		return iSitioDao;
	}

	public void setiSitioDao(ISitioDao iSitioDao) {
		this.iSitioDao = iSitioDao;
	}

	

}